package com.zja.servlet;


import com.zja.model.JsonResponse;
import com.zja.util.ServletUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
/**
    *@author JA
    * @date: 2025/5/3
     * description:注销登录
 */

@WebServlet("/api/auth/logout")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=UTF-8");
        req.setCharacterEncoding("UTF-8");

        // 清除 session
        req.getSession().invalidate();

        // 使用统一的响应格式
        ServletUtil.writeJsonResponse(resp, JsonResponse.success("已成功退出登录"));
    }
}
